{# required vars: rw: coming from canread or canwrite #}
{# default icon/label are for canread #}
{# twigcs use-var can #}
{# see https://github.com/friendsoftwig/twigcs/issues/121 #}
{% set icon = 'eye' %}
{% set label = 'Visibility'|trans %}
{% set modalTitle = 'Select who can see this entry'|trans %}
{% set immutableVar = rw ~ '_is_immutable' %}
{% if rw == 'canwrite' or rw == 'canwrite_target' %}
  {% set icon = 'pencil-alt' %}
  {% set label = 'Can write'|trans %}
  {% set modalTitle = 'Select who can edit this entry'|trans %}
{% elseif rw == 'canbook' %}
  {% set icon = 'calendar-plus' %}
  {% set label = 'Can book'|trans %}
  {% set modalTitle = 'Select who can book this entry'|trans %}
{% endif %}

{% include('permissions-edit-modal.html') %}
<label class='col-form-label mr-3 edit-mode-label'><i class='fas fa-fw fa-{{ icon }} mr-1' title='{{ label }}'></i>{{ label }}</label>
{% if not Entity.isReadOnly %}
  {% set permissionsIsDisabled = false %}
  {% if Entity.entityData[immutableVar] and Entity.entityType.value != 'experiments_templates' and Entity.entityType.value != 'items_types' and not App.Users.isAdmin %}
    {% set permissionsIsDisabled = true %}
  {% endif %}
  {# show the button as disabled and without any action related #}
  <button type='button' title='{{ modalTitle }}' aria-label='{{ modalTitle }}' class='btn border-0 lh-normal {{ not permissionsIsDisabled ? 'hl-hover-gray' }}' data-action='{{ not permissionsIsDisabled ? 'toggle-modal' }}' data-target='permModal-{{ rw }}' {{ permissionsIsDisabled ? 'disabled' }}>
    <i class='fas fa-fw fa-square-plus fa-2x'></i>
  </button>
{% endif %}
<div class='vertical-separator'></div>
{% include('view-permissions-details.html') %}
